

/*
 * @Autor: Mr Lu
 * @Version: 1.0
 * @Date: 2019-12-03
 * @LastEditors: OBKoro1
 * @LastEditTime: 2019-12-03
 * @Description:  列表加载
   refreshing	是否正在刷新数据	Boolean	—	false
   loading	是否正在加载数据	Boolean	—	false
   loading-text	加载文字	String	—	—
   loaded-all	数据是否已全部加载	Boolean	—	—
 */
<template>
  <div class="MeasureList p-box">
    <div class="p-return">
      <mu-appbar color="primary" class="lan-header">
        <mu-button icon slot="left" v-close>
          <i class="iconfont angle-left iconangle-left"></i>
          <span class="lan-header-back">返回</span>
        </mu-button>实测实量
      </mu-appbar>
    </div>
    <div class="p-content">
      <div ref="container" class="listContainer">
        <mu-load-more
          v-if="data.length"
          @refresh="refresh"
          :refreshing="refreshing"
          :loading="loading"
          :loaded-all="loadAll"
        >
          <!-- 这里是业务结构 -->
          <mu-paper class="lan-card" :z-depth="1" v-for="(item,index) in data" :key="index">
            <div class="lan-detail">
              <span class="lan-detail-h">项目名称：</span>
              <span class="lan-detail-r">{{item.projectName}}</span>
            </div>
            <div class="lan-detail">
              <span class="lan-detail-h">实测区域：</span>
              <span class="lan-detail-r">{{item.areaName}}</span>
            </div>
            <div class="lan-detail">
              <div class="lastFlex">
                <div>
                  <span class="lan-detail-h">实测点位数：</span>
                  <span class="lan-detail-r">{{ JSON.parse(item.point.replace(/'/g, '"')).length}}</span>
                </div>
                <div>
                  <mu-button
                    small
                    color="primary"
                    @click="goMeasure(item)"
                    :disabled="item.status=='1'"
                  >进行测量</mu-button>
                </div>
              </div>
            </div>
          </mu-paper>
          <p v-if="loadAll" class="nodataTips">无更多数据了</p>
        </mu-load-more>
        <NoData v-if="!data.length&&!listLoading" />
      </div>
    </div>
  </div>
</template>
<script>
import mTabs from "@/tabs/mTabs";
export default {
  name: "MapShow",
  components: {
    mTabs
  },
  props: ["listParams"],
  data() {
    return {
      refreshing: false,
      loading: false,
      loaded: false,
      loadAll: false,
      pageSize: 10,
      pageNo: 0,
      totalPage: 1,
      data: [],
      detailController: false,
      Detail: {},
      form: {},
      listLoading: false,
      projectList: []
    };
  },
  watch: {},
  async created() {},
  mounted() {
    this.refresh();
  },
  methods: {
    async refresh() {
      this.refreshing = true;
      this.pageNo = 0;
      this.totalPage = 1;
      this.loaded = false;
      this.loadAll = false;
      this.data = [];
      this.$refs.container.scrollTop = 0;
      await this.getData();
      this.refreshing = false;
    },
    async getData() {
      this.$openLoading();
      this.listLoading = true;
      this.$A.Go("get", "/safety/measureTask/dataList", this.$route.query).then(
        success => {
          if (success.code == 200) {
            this.data = success.body || [];
          } else {
            this.data = [];
          }
          this.loadAll = true;
          this.loaded = true;
          this.$closeLoading();
          this.listLoading = false;
        },
        err => {
          this.$closeLoading();
          console.warn(err);
          this.listLoading = false;
        }
      );
    },
    dealPoint(data) {
      return;
    },
    search() {
      this.loaded = false;
      this.loadAll = false;
      this.pageSize = 10;
      this.pageNo = 0;
      this.totalPage = 1;
      this.data = [];
      this.getData(this.form);
    },
    clearSearch() {
      this.form = {
        projectId: "",
        startMeetTime: "",
        endMeetTime: "",
        meetType: "",
        meetName: ""
      };
    },
    goMeasure(params) {
      this.$router.push({
        path: "StartMeasure",
        query: {
          id: params.id,
          areaId: params.areaId,
          areaName: params.areaName,
          deptId: params.deptId,
          deptName: params.deptName,
          areaName: params.areaName,
          photoUrl: params.photoUrl,
          projectId: params.projectId,
          projectName: params.projectName,
          pointList: JSON.stringify(params.measurePointVoList)
        }
      });
    },
    handurl(str) {
      if (!str) {
        return [];
      } else {
        return str.split(",");
      }
    },
    loadFile(list) {
      let a = document.createElement("a");
      a.setAttribute("href", list.url);
      a.setAttribute("download", list.name);
      a.click();
    }
  }
};
</script>

<style lang="scss" scoped>
.img-box {
  img {
    width: 80px;
    height: 80px;
    float: left;
    margin: 5px 8px;
  }
}
.lan-form-title {
  line-height: 40px;
}
</style>